package br.com.fip.dao;

import org.hibernate.Session;

import br.com.fip.model.BancoDeHoras;
import br.com.fip.util.Log;

public class BancoDeHorasDAO {
	
	private Session session;
	
	public void registrarEvento(BancoDeHoras bancoDeHoras, Session session){
		this.session = session;
		try{
			this.session.beginTransaction();
			this.session.merge(bancoDeHoras);
			this.session.getTransaction().commit();
		}catch(IllegalArgumentException e){
			e.printStackTrace();
			Log.getLogger().error(e);
		}
	}
	
	public void atualizarBanco(BancoDeHoras bancoDeHoras, Session session){
		this.session = session;
		try{
			this.session.beginTransaction();
			this.session.merge(bancoDeHoras);
			this.session.getTransaction().commit();
		}catch(IllegalArgumentException e){
			e.printStackTrace();
			Log.getLogger().error(e);
		}
	}
	
	public void inserirBanco(BancoDeHoras bancoDeHoras, Session session){
		this.session = session;
		try{
			this.session.beginTransaction();
			this.session.save(bancoDeHoras);
			this.session.getTransaction().commit();
		}catch(IllegalArgumentException e){
			e.printStackTrace();
			Log.getLogger().error(e);
		}
	}

}
